package week2.day10;

/**
 * @Author fengzihao
 * @Date 2024-04-24 14:00
 */
public class TestFind{
    public static void main(String[] args) {
        Grandfather grandfather = new Son(1,2,3,4,5,6);
        Father father = new Son(1,2,3,4,5,6);
        Son son = new Son(1,2,3,4,5,6);

        System.out.println("grandfather.a = " + grandfather.a);
        System.out.println("grandfather.gA = " + grandfather.gA);
        grandfather.test();
        grandfather.testGrand();

        System.out.println("father.a = " + father.a);
        System.out.println("father.fA = " + father.fA);
        System.out.println("father.gA = " + father.gA);
        father.test();
        father.testFather();
        father.testGrand();

        System.out.println("son.a = " + son.a);
        System.out.println("son.sA = " + son.sA);
        System.out.println("son.fA = " + son.fA);
        System.out.println("son.gA = " + son.gA);
        son.test();
        son.testSon();
        son.testFather();
        son.testGrand();

    }
}

class Grandfather {
    public int gA;
    public int a;

    public Grandfather() {
    }

    public Grandfather(int gA, int a) {
        this.gA = gA;
        this.a = a;
    }

    public void testGrand(){
        System.out.println("testGrand in Grandfather");
    }
    public void test(){
        System.out.println("test in Grandfather");
    }


}

class Father extends Grandfather{
    public int a;
    public int fA;

    public Father() {
    }

    public Father(int gA, int a, int a1, int fA) {
        super(gA, a);
        this.a = a1;
        this.fA = fA;
    }

    public void testFather(){
        System.out.println("testFather in Father");
    }
    public void test(){
        System.out.println("test in Father");
    }
}

class Son extends Father{
    public int a;
    public int sA;

    public Son() {
    }

    public Son(int gA, int a, int a1, int fA, int a2, int sA) {
        super(gA, a, a1, fA);
        this.a = a2;
        this.sA = sA;
    }

    public void testSon(){
        System.out.println("testSon in Son");
    }
    public void test(){
        System.out.println("test in Son");
    }
}